<?php
    class UserAction extends Action{
        public function index(){
           $m=M("User");
           $arr=$m->select();
//           var_dump($arr);
           $this->assign("data",$arr);
           $this->display();
        }
        public function del(){
            $m=M('User');
            $id=$_GET["id"];
            $count=$m->delete($id);
            if($count>0){
                $this->success("数据删除成功...");
            }else{
                $this->error("数据删除失败..");
            }
        }
        /******显示修改页面*******/
        public function modify(){
            $m=M("User");
            $id=$_GET["id"];
            $arr=$m->find($id);
            var_dump($arr);
            $this->assign('data',$arr);
            $this->display();
        }
        /*****查询数据*********/
        public function search(){
            $m=M("User");
            if(isset($_POST['username']) && $_POST['username']!=null){
                  $where['username']=array('like',"%{$_POST['username']}%");
            }
            if(isset($_POST['sex']) && $_POST['sex']!=null){
                $where['sex']=array('eq',$_POST['sex']);
            }
            
            $arr=$m->where($where)->select();
            $this->assign('data',$arr);
            $this->display('index');
        }
        
        public function demo(){
            $m=M('User');
            $arr=$m->order(array("id"=>"desc"))->limit('2,3')->field('username',true)->select();
            dump($arr);
            $this->show('abc');
        }
    }
?>